import * as components from "@/components/low-code/page-designer/pc-library/base-components/widget/index"
import renderParse from "../parse/index.vue"
import pageRender from "../render/index.vue"
import { LowCode } from "@/components/low-code/core"

type Params = { custom: { config: any, widget: any, setting?: any }[] }
const install = function (app: any, opts: Params) {
    for (const [key, component] of Object.entries(components)) {
        app.component(key + 'Render', component)
    }
    app.component("renderParse", renderParse)
    app.component("pageRender", pageRender)

    /****
     * 注册自定义组件
     */
    if (opts?.custom && opts?.custom.length > 0) {
        LowCode.custom = opts?.custom
        console.log(opts.custom)
        opts.custom.map(item => {
            app.component(item.config.type + 'WidgetRender', item.widget)
        })
    }

}


export default install